<template>
	<div class="pagesListcont">
		<div class="listItems">
			<div class="listItems_title">
				<div class="listItems_title_left">
					{{ite.title}}
				</div>
				<!-- 	<div class="listItems_title_right" :class="'roomColor'+ite.status">
					{{ite.status | statusFilterSB}}
				</div> -->
			</div>
			<div class="listItems_cont">
				<p>发起人：{{ite.name || ''}}</p>
				<p>换房时间：{{ite.addtime || ''}}</p>
				<p>原房间号：{{ite.room_name || ''}}</p>
				<p>新房间号：{{ite.room_names || ''}}</p>
				<p>创建时间：{{ite.addtime || ''}}</p>
			</div>

		</div>


		<div class="">
			<div class="liveInformationItems" v-for='(ite,idx) in listTab' :key="idx">
				<div class="liveInformationItems_left">
					{{ite.name}}
				</div>
				<div class="liveInformationItems_right">
					<div class="useLable">
						<u-switch v-model="ite.status" @change="changeSwitch" activeColor="#295EFF"></u-switch>
					</div>
				</div>
			</div>
		</div>
		<div class="space">

		</div>

		<div :class="isRead===1?'inviteIndexItems_btn':'inviteIndexItems_btn color_hui' "
			@click='quedingEvent(ite,ite.anchor_id)'>
			确认
		</div>

	</div>
</template>

<script>
	export default {
		// 1正常 2维修中 3报废 4故障
		filters: {
			statusFilterSB(v) {
				var s = ''
				// 1可预定 2待入驻 3已入住 4待搬离 5未保洁
				switch (v) {
					case '1':
						s = '正常'
						break;
					case '2':
						s = '维修中'
						break;
					case '3':
						s = '报废'
						break;
					case '4':
						s = '故障'
						break;
				}
				return s
			}
		},
		props: {
			list: [Array, String],
			pageType: [Array, String, Number],
		},
		data() {
			return {
				froolShow: false,
				from: {},
				equipment_id: '',
				userStatus: uni.getStorageSync('userStatus'),
				listShow: [],
				ite: {},
				isRead: '',
				listTab: [{
						name: '核对设备',
						status: false
					},
					{
						name: '家具家电',
						status: false
					},
					{
						name: '房间装修',
						status: false
					},
					{
						name: '水电费',
						status: false
					},
					{
						name: '房间密码修改',
						status: false
					},
					{
						name: '餐券/饭卡收回',
						status: false
					},
					{
						name: '群聊转移',
						status: false
					},
					{
						name: '钉钉转移',
						status: false
					},
					{
						name: '行李转移',
						status: false
					}
				]
			}
		},
		watch: {
			list(newVal, oldVal) {
				this.listShow = newVal
			}
		},
		onLoad(opt) {
			console.log('11111', opt)
			this.ite = JSON.parse(opt.ite)
			this.getSopServer(this.ite)
		},
		methods: {
			async getSopServer(ite) {
				const {
					data
				} = await this.$request(this.$Api.worksMessage, {
					work_id: ite.work_id || ite.id || 1720321765
				}, "post")
				if (data.code != 0) return
				// console.log('data.data.length',data.data.length)
				if (data.data.length <= 0) return
				this.listTab = data.data
			},

			changeSwitch() {
				this.isRead = 1
				for (var i in this.listTab) {
					console.log('this.listTab[i].status', this.listTab[i].status)
					if (this.listTab[i].status == false) {
						this.isRead = 2
						continue;
					}
				}
				// 数据存储
				this.saveData(this.ite)
			},
			async saveData(ite) {
				const {
					data
				} = await this.$request(this.$Api.worksSave, {
					work_id: ite.work_id || ite.id || 1720321765,
					data: JSON.stringify(this.listTab)
				}, "post")
				if (data.code != 0) return
			},
			// anchorList
			qianwangEvetn() {
				uni.navigateTo({
					url: '/pages/invite/invite?status=' + this.userStatus
				})
			},
			async quedingEvent(e, id) {
				console.log('anchor_id', e, id)
				if (this.isRead != 1) return uni.showToast({
					title: '请确认完再进行尝试',
					icon: 'none'
				})
				const {
					data
				} = await this.$request(this.$Api.noticesSuress, {
					anchor_id: id,
					'id': e.id
				}, "POST")
				uni.showToast({
					title: '操作成功',
					icon: 'none'
				});
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let nowPage = pages[pages.length - 1]; //当前页页面实例
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				prevPage.$vm.isRefresh = true; //修改上一页data里面的isRefresh
				uni.navigateBack({
					// 返回的页面层数
				});
				// this.$set('upDate')
			}
		}
	}
</script>

<style lang="less">
	.pagesListcont {
		.listItems {
			width: 100%;
			min-height: 422rpx;
			background: #FFFFFF;
			border-radius: 12rpx;
			margin: 20rpx auto 0 auto;
			padding: 0 40rpx;
			box-sizing: border-box;
			font-size: 32rpx;
			color: #000;

			.listItems_btn {
				display: flex;
				align-items: center;
				justify-content: flex-end;
				width: 100%;
				height: 120rpx;

				.btn {
					width: 164rpx;
					height: 68rpx;
					background: #FFFFFF;
					border: 2rpx solid #999999;
					margin-left: 26rpx;
					text-align: center;
					line-height: 68rpx;

				}

				.listItems_btn_zj {
					color: #fff;
					border: 2rpx solid #9013FE;
					background: #9013FE;
				}

				.listItems_btn_cl {
					color: #fff;
					border: 2rpx solid #2D60FF;
					background: #2D60FF;
				}

			}

			.listItems_title {
				display: flex;
				align-items: center;
				justify-content: space-between;
				height: 108rpx;
				width: 100%;
			}

			.listItems_title_right {
				color: #FF1D1D;
			}

			.listItems_cont {
				p {
					color: #666;
					font-size: 28rpx;
					margin-bottom: 14rpx;
				}
			}

			.listItems_bz {
				min-height: 10rpx;
				padding: 10rpx 0 30rpx 0;
				border-bottom: 1px solid #DDDDDD;
				color: #666;
				font-size: 28rpx;

			}
		}
	}

	.liveInformationItems {
		width: 100%;
		height: 104rpx;
		border-bottom: 1rpx solid #E3E8EE;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 28rpx;
		color: #464C5B;
		padding: 0 32rpx;

		.liveInformationItems_left {
			width: 550rpx;

			span {
				color: #FF5A5F;
			}
		}

		.liveInformationItems_right {}

	}

	.inviteIndexItems_btn {
		width: 750rpx;
		height: 100rpx;
		background: #9013FE;
		line-height: 100rpx;
		font-size: 28rpx;
		text-align: center;
		color: #fff;
	}

	.color_hui {
		background: #666 !important;
	}
</style>